package com.welsy.authoring.business
{
	/**
	  * An utility class  for file format handling
	  * @author Welsy.org
	  */
	public class FileRepositoryManager
	{
        public static var IMAGE:String = "*.jpg;*.gif;*.png;";
		
		public static var OFFICE:String = "*.doc;*.xls;*.pdf;";
		
		public static var PPT:String = "*.ppt;";
		
		public static var SWF:String = "*.swf;*.pdf;";
		
		public static var VIDEO:String = "*.flv;*.mov;*.avi;*.mpg;";
		
		public static var MHT:String = "*.mht;";
		
		public static var AUDIO:String = "*.mp3;";
		
		public static var TEST:String = "*.jpg;*.gif;*.png;*.swf;*.flv;*.mov;*.avi;*.mpg;";
		
		
		/** 
		  * Recognize the format of a file using the extension
		  * @param filename The name of the file
		  * @return A code describing the file format, or an empty string if not recognized
		  * 2: office
		  * 3: presentation
		  * 6: mht
		  * 7: video
		  * 8: swf
		  * 9: image
		  * 10: mp3
		  */
		public function GetTypeFile(filename:String):String {
			var extFile:String = filename.substr(filename.lastIndexOf(".")+1).toLowerCase()
			switch (extFile) {
					case "jpg":
					case "gif":
					case "png":					
						return "9";
					case "doc":
					case "xls":
					case "pdf":
						return "2";
					case "ppt":
						return "3";
					case "swf":
						return "8";
					case "flv":
					case "mov":
					case "avi":
					case "mpg":
						return "7";
					case "mht":
						return "6";
					case "mp3":
						return "10";				
					default:
						return "";
				}			
		}
	}
}